package com.ruantu.clothing.service;

import com.ruantu.clothing.dao.RukuMapper;
import com.ruantu.clothing.dao.TuihuoMapper;
import com.ruantu.clothing.entity.TailorRuku;
import com.ruantu.clothing.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/7/31 0031.
 */
@Service
public class ScriptServiceImpl {
    @Autowired
    private TuihuoMapper tuihuoMapper;
    @Autowired
    private RukuMapper rukuMapper;

    public List<TailorRuku> isnertTailorRuku() {
        List<TailorRuku> list = tuihuoMapper.findRukuCjid();
        List<TailorRuku> shuju = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            String cjid[] = list.get(i).getTailorId().split(",");
            for (int j = 0; j < cjid.length; j++) {
                TailorRuku tailorRuku = new TailorRuku();
                tailorRuku.setId(UUIDUtil.getUUID());
                tailorRuku.setTailorId(cjid[j]);
                tailorRuku.setRukuId(list.get(i).getRukuId());
                shuju.add(tailorRuku);
            }
        }
        rukuMapper.insertTailorRuku(shuju);
        return null;
    }

}
